package cn.pugle.oj.leetcode;

import cn.pugle.oj.catalog.DaiBi;
import cn.pugle.oj.catalog.Unknown;

import java.util.ArrayList;
import java.util.List;

/**
 * 118 119
 *
 * @author tzp
 * @since 2020/11/18
 */
public class LC118 implements DaiBi {
    public List<List<Integer>> generate(int numRows) {
        ArrayList<List<Integer>> result = new ArrayList<>(numRows);
        for (int i = 0; i < numRows; i++) {
            ArrayList<Integer> row = new ArrayList<>();
            for (int j = 0; j < i + 1; j++) {
                if (j == 0 || j == i) {
                    row.add(1);
                } else {
                    int x = result.get(i - 1).get(j - 1) + result.get(i - 1).get(j);
                    row.add(x);
                }
            }
            result.add(row);
        }
        return result;
    }

    public static void main(String[] args) {
        System.out.println(new LC118().generate(10));
    }
}
